package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.StrategyCatalog;
import cn.wolfcode.luowowo.article.service.IStrategyCatalogService;
import cn.wolfcode.luowowo.common.query.StrategyCatalogQuery;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/strategyCatalog")
public class StrategyCatalogController {
    @Reference
    private IStrategyCatalogService strategyCatalogService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") StrategyCatalogQuery qo, Model model) {
        model.addAttribute("pageInfo",strategyCatalogService.query(qo));
        return "strategyCatalog/list";
    }

    @ResponseBody
    @RequestMapping("/saveOrUpdate")
    public Object saveOrUpdate(StrategyCatalog catalog) {
        AjaxResult result = new AjaxResult();
        try {
            strategyCatalogService.saveOrUpdate(catalog);
        } catch (Exception e) {
            e.printStackTrace();
            result.mark("操作失败");
        }
        return result;
    }
}
